<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input onkeyup="test1(event)"/>测试键盘事件
    <input onkeyup="test2(event)"/>测试回车键


</body>

<script type="text/javascript">

    function test1(e) {
        console.log("触发了键盘事件", e)
    }
    function test2(e){
        if(e.keyCode != 13) return;
        console.log("按下了回车键")
    }
</script>

</html>